package cn.iocoder.yudao.module.biz.dal.dataobject.licenceAudit;

import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * 审核人员 DO
 *
 * @author 芋道源码
 */
@TableName("biz_licence_audit")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BizLicenceAuditDO extends BaseDO {

    /**
     *
     */
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;
    /**
     * 序号
     */
    private Integer number;
    /**
     * 审核用户id
     */
    private String auditUserId;
    /**
     *
     */
    private String licenceId;
    /**
     * 状态（-1未审核，0审核中，1审核结束）
     */
    private Integer status;
    /**
     * 是否为最后一个审核人
     */
    private Boolean lastUser;
    /**
     * 租户编号
     */
    private String tenantId;
    /**
     * 审核人姓名
     */
    private String auditUserName;

    public static BizLicenceAuditDO of(Integer number, String licenceId, String auditUserId, Integer status, Boolean lastUser, String auditUserName) {
        BizLicenceAuditDO bizLicenceAuditDO = new BizLicenceAuditDO();
        bizLicenceAuditDO.setNumber(number);
        bizLicenceAuditDO.setLicenceId(licenceId);
        bizLicenceAuditDO.setAuditUserId(auditUserId);
        bizLicenceAuditDO.setStatus(status);
        bizLicenceAuditDO.setLastUser(lastUser);
        bizLicenceAuditDO.setAuditUserName(auditUserName);
        bizLicenceAuditDO.setUpdateTime(localDateTimeToDate(LocalDateTime.now()));
        return bizLicenceAuditDO;
    }


    public static Date localDateTimeToDate(LocalDateTime localDateTime) {
        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
    }

}
